﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer
{
    class ReportFacade
    {   InventorySoreDataContext context;
        public ReportFacade()
        {
            context = new InventorySoreDataContext();
        }
        public IQueryable FindReorderReportBySelectedMonth(int sMonth, int year)
        {
            var items = (from it in context.Items
                         join od in context.OrderDetails on it.ItemCode equals od.ItemCode
                         join o in context.Orders on od.PONo equals o.PONo
                         where o.ExpectedDate.Value.Month == sMonth && o.ExpectedDate.Value.Year == year
                         select new
                         {
                             ItemCode = it.ItemCode,
                             Description = it.Description,
                             Stock = it.Stock,
                             ReorderLevel = it.ReorderLevel,
                             ReorderQty = it.ReorderQty,
                             PONo = od.PONo,
                             ExpectedDate = o.ExpectedDate
                         });
            return items;
        }
    }
}
